﻿<template>
  <!--    引入container布局-->
  <el-container class="home-container">
    <el-header>
      <div>
        <span>部门信息管理系统</span>
      </div>
        <el-button type="danger" icon="el-icon-close" @click="logout" circle></el-button>


    </el-header>
    <!--        主体-->
    <el-container>
      <!--            侧边栏-->
      <el-aside width="200px">
        <el-menu :default-active="$route.path"
                 class="el-menu-vertical-demo"
                 router
                 @open="handleOpen"
                 @close="handleClose"
                 background-color="#545c64"
                 text-color="#fff"
                 active-text-color="#ffd04b">
          <el-menu-item  index="/index">
            <i class="el-icon-location"></i>
            <span slot="title">首页</span>
          </el-menu-item>
          <el-menu-item  index="/home/department">
            <i class="el-icon-location"></i>
            <span slot="title">部门管理</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <!--            主体内容-->
      <el-main>
        <router-view>

        </router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
  export default {
    data(){
      return{
        name:window.sessionStorage.getItem("name")
      }
    },
    //onload事件
    created() {
      //回车监听事件
      var _this = this;
      document.onkeydown = function(e) {
        let key = window.event.keyCode;
        if (key == 13) {
          _this.login();
        }
      }
      //const _this = this
      _this.name=window.sessionStorage.getItem("name")

    },
    methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },
      //安全退出
      logout() {
        window.sessionStorage.clear();//清除session
        this.$router.push("/login");
      },
      update(){
        this.$router.push("/home/message");
      },
    },

  }
</script>
<style lang="less" scoped>
  .el-header {
    background-color: #373d41;
    display: flex;
    justify-content: space-between; // 左右贴边
    padding-left: 0%; // 左边界
    align-items: center; // 水平
    color: #fff;
    font-size: 20px;

    > div { //左侧div加布局
      display: flex;
      align-items: center;

      span {
        margin-left: 15px;
      }
    }
  }

  .el-aside {
    background-color: #333744;

    .el-menu {
      border-right: none; // 对其右边框
    }
  }

  .el-main {
    background-color: #eaedf1;
  }

  .home-container {
    height: 100%;
  }

  .logo_img {
    width: 20%;
    height: 100%;
  }

  .iconfont {
    margin-right: 10px;
  }

  .toggle-button {
    background-color: #4A5064;
    font-size: 10px;
    line-height: 24px;
    color: #fff;
    text-align: center;
    letter-spacing: 0.2em;
    cursor: pointer; // 显示鼠标指针为：小手
  }
</style>
